package mobidever.godutch.activity.base;

import mobidever.godutch.activity.R;
import mobidever.godutch.controls.SlideMenuView;
import mobidever.godutch.controls.SliderMenuItem;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;

public class ActivityFrame extends ActivityBase {
	private SlideMenuView mSlideMenuView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);

		setContentView(R.layout.main);
	}

	protected void AppendMainBody(int pResID) {
		LinearLayout _MainBody = (LinearLayout) findViewById(R.id.layMainBody);
		View _View = LayoutInflater.from(this).inflate(pResID, null);
		RelativeLayout.LayoutParams _LayoutParams = new LayoutParams(
				RelativeLayout.LayoutParams.FILL_PARENT,
				RelativeLayout.LayoutParams.FILL_PARENT);
		_MainBody.addView(_View, _LayoutParams);
	}

	protected void AppendMainBody(View pView) {
		LinearLayout _MainBody = (LinearLayout) findViewById(R.id.layMainBody);
		RelativeLayout.LayoutParams _LayoutParams = new RelativeLayout.LayoutParams(
				LinearLayout.LayoutParams.FILL_PARENT,
				LinearLayout.LayoutParams.FILL_PARENT);
		_MainBody.addView(pView, _LayoutParams);
		// _View.setPadding(15,15,15,15);
	}

	protected void CreateSlideMenu(int pResID) {
		mSlideMenuView = new SlideMenuView(this);
		String[] _MenuItemArray = getResources().getStringArray(pResID);
		for (int i = 0; i < _MenuItemArray.length; i++) {
			SliderMenuItem _Item = new SliderMenuItem(i, _MenuItemArray[i]);
			mSlideMenuView.Add(_Item);
		}
		mSlideMenuView.BindList();
	}

	protected void SlideMenuToggle() {
		mSlideMenuView.Toggle();
	}

	protected void CreateMenu(Menu pMenu) {
		int _Item[] = { 1, 2 };
		int _GroupID = 0;
		int _Order = 0;
		for (int i = 0; i < _Item.length; i++) {
			switch (_Item[i]) {
			case 1:
				pMenu.add(_GroupID, _Item[i], _Order, R.string.MenuTextEdit);
				break;
			case 2:
				pMenu.add(_GroupID, _Item[i], _Order, R.string.MenuTextDelete);
			default:
				break;
			}
		}
	}

	protected void SetTopBarTitle(String pText) {
		// String _Title = FormatResString(pRestID);
		TextView _tvTitle = (TextView) findViewById(R.id.tvTopTitle);
		_tvTitle.setText(pText);

		// ImageView _ImageView = (ImageView) findViewById(R.id.ivBottomIcon);
		// _ImageView.setImageResource(R.drawable.account_book_32x32);
	}

	protected void RemoveBottomBox() {
		mSlideMenuView = new SlideMenuView(this);
		mSlideMenuView.RemoveBottomBox();
	}
}
